package com.zut.hospital.controller.examination;

import com.alibaba.fastjson.JSONObject;
import com.zut.hospital.service.examination.PhyexamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @PackageName:com.zut.hospital.controller.examination
 * @Date:2019/5/28 17:14
 * @Author: zsy
 */
@Controller
@ResponseBody
public class PhyexamController {
    @Autowired
    PhyexamService phyexamService;

    @PostMapping("/pro2stu")
//    @ResponseBody
    public void addPro2Stu(@RequestBody String data) {
        Integer deptId = Integer.parseInt(JSONObject.parseObject(data).getString("deptId"));
        phyexamService.addPerson(deptId);
    }

    @PostMapping("/result2stu")
    public void addResult2Stu(@RequestBody String data) {
        Integer stuId = Integer.parseInt(JSONObject.parseObject(data).getString("stuId"));
        Integer pro1Id = Integer.parseInt(JSONObject.parseObject(data).getString("pro1Id"));
        String result1 = JSONObject.parseObject(data).getString("result1");
        Integer pro2Id = Integer.parseInt(JSONObject.parseObject(data).getString("pro2Id"));
        String result2 = JSONObject.parseObject(data).getString("result2");
        Integer pro3Id = Integer.parseInt(JSONObject.parseObject(data).getString("pro3Id"));
        String result3 = JSONObject.parseObject(data).getString("result3");
        Integer pro4Id = Integer.parseInt(JSONObject.parseObject(data).getString("pro4Id"));
        String result4 = JSONObject.parseObject(data).getString("result4");
        Integer pro5Id = Integer.parseInt(JSONObject.parseObject(data).getString("pro5Id"));
        String result5 = JSONObject.parseObject(data).getString("result5");
        Integer pro6Id = Integer.parseInt(JSONObject.parseObject(data).getString("pro6Id"));
        String result6 = JSONObject.parseObject(data).getString("result6");
        phyexamService.addOneResult(stuId, pro1Id, result1);
        phyexamService.addOneResult(stuId, pro2Id, result2);
        phyexamService.addOneResult(stuId, pro3Id, result3);
        phyexamService.addOneResult(stuId, pro4Id, result4);
        phyexamService.addOneResult(stuId, pro5Id, result5);
        phyexamService.addOneResult(stuId, pro6Id, result6);
    }
}
